<template>
  <div id="app">
      <router-view  v-if="isRouterAlive"/>
  </div>
</template>
<script>
// import state from "@/store/state.js";
// import indexJs from "@/store/index.js";
// import types from "@/constants/types";
import { mapState } from "vuex";

import { banBackSpace } from "@/constants/banBackSpace.js";

export default {
  name: "App",
  provide () {    //父组件中通过provide来提供变量，在子组件中通过inject来注入变量。
    return {
        reload: this.reload
    }
  },
  data(){
    return {
      isRouterAlive: true
    }
  },
  watch: {
    // "$route.path": function (newVal, oldVal) {
    //   // console.log(newVal);
    //   sessionStorage.setItem("route", newVal);
    // }
  },
  mounted() {
    window.addEventListener("beforeunload", this.saveState);
    this.preventBackSpace();
  },
  beforeDestroy() {
    window.removeEventListener("beforeunload", this.saveState);
  },
  created(){
    console.log(`                                         .
                  .JbBQBQBQQ2i
                .PBQBQg2KKQQBQQr
              vQBQP:      .vBQBP.
              rQRgr           MQB1
              dMDL            .B:
          75MQBMB.                7MZ7.
        sBQBQR5hh.              .gQBQBQE.
      .gBQQr                  .5BQBs:IBQBr
      gQgK        r.         uQBQZ.   iQZBr
    JBdd       iRBDu      iQQBgr      rQEQ
    DEQr        rPBQ5   :PBQBL         EDR:
    hQDs          7:   5QBQP          .RbB.
    7QgZ.            rBQBE:           hZQP
      PQQgi         :EBQBr            PMQQ.
      2QBQg7.   :rgQBQS   :dX:.   r2BQBE.
        .IBQBQBQBQBQB5:   rQBQBQBQBQBQgi
          ivKPgPKvi        .v1EPDX2i.
                                              `);

  },
  methods: {
    reload () {
        this.isRouterAlive = false;            //先关闭，
        this.$nextTick(function () {
            this.isRouterAlive = true;         //再打开
        })
    },
    saveState() {
      let { userInfo } = this.$store.state;
      let simpleState = { userInfo};
      // console.log("************",simpleState)
      sessionStorage.setItem("state", JSON.stringify(simpleState));
    },
    //阻止backspace键退出上一层
    preventBackSpace() {
      document.onkeypress = banBackSpace;
      document.onkeydown = banBackSpace;
    },
  },
  computed: {
    ...mapState({
      // userInfo: ["userInfo"],
      // personalDetails: ["personalDetails"]
    }),
    st() {
      // console.log(this.$refs.caseContainer.scrollTop);
      return this.$refs.caseContainer.scrollTop;
    }
  },
  watch:{
    '$route.query':{
      handler(val){
        // console.log("**********",val);
        this.$nextTick(()=>{
          if(val&&val.key){
            this.handleZYW(val);
          }
        })
      },
      immediate:true,
      deep:true,
    }
  }
};
</script>
<style>
#app {
  min-height: 100%;
  /*max-width: 1920px;*/
  margin: auto;
}
#app>div{
  min-width: 1000px;
  min-height: 100.1vh;
}

body{
  font-size: 16px;
  padding: 0!important;
}
ul {
  list-style: none;
}
a {
  text-decoration: none;
}
img {
  vertical-align: top;
  border: none;
}
* {
  padding: 0;
  margin: 0;
}
.clearf:after,
.clearf:before {
  content: "";
  display: block;
  clear: both;
}
table {
  margin: 0;
}
div,
p,
span {
  word-wrap: break-word;
}
::-webkit-scrollbar-thumb:horizontal {
  width: 4px;
  background-color: #ccc;
}
::-webkit-scrollbar-track-piece {
  background-color: #fff; /*滚动条的背景颜色*/
  border-radius: 2px;
  -webkit-border-radius: 2px; /*滚动条的圆角宽度*/
}
::-webkit-scrollbar {
  width: 8px; /*滚动条的宽度*/
  height: 8px; /*滚动条的高度*/
}
::-webkit-scrollbar-thumb:vertical {
  width: 4px;
  background-color: #cccccc;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #909399;
}
.qrcode_xhw {
  min-width: 100px !important;
}
</style>
// <style lang="less">
// @import "./common/font/font.css";
// </style>
